package com.qifan.alb2b.action.back;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qifan.alb2b.domain.ConfigInfoDomain;
import com.qifan.alb2b.service.ConfigInfoService;
import com.qifan.alb2b.util.DataGridModel;
import com.qifan.alb2b.util.Page;

@Controller
@RequestMapping("/admin/config")
public class ConfigManageController{
	private ConfigInfoService configInfoService;

	public void setConfigInfoService(ConfigInfoService configInfoService) {
		this.configInfoService = configInfoService;
	}
	
	@RequestMapping("/query.adm")
	@ResponseBody
	public Page query(DataGridModel dgm,ConfigInfoDomain uqp) {
		//spring太给力了，可以自动装配两个对象  会自动的装返回的Map转换成JSON对象
		return configInfoService.query(dgm,uqp);
	}
	
	@RequestMapping("/add.adm")
	@ResponseBody
	public Map<String, Object> add(ConfigInfoDomain configInfoDomain){
		Map<String, Object> map=new HashMap<String, Object>();
		configInfoDomain.setCreateTime(new Date());
		configInfoService.add(configInfoDomain);
		map.put("success", true);
		return map;
	}
	
	@RequestMapping("/update")
	@ResponseBody
	public Map<String, Object> update(ConfigInfoDomain configInfoDomain){
		
		Map<String, Object> map=new HashMap<String, Object>();
		configInfoDomain.setCreateTime(new Date());
		configInfoService.update(configInfoDomain);
		map.put("success", true);	
		return map;
	}
	
}
